<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8" />
    <title>系统访问</title>
	<link rel="stylesheet" type="text/css" href="/static/basic/plugins/easyui/themes/bootstrap/easyui.css">
	<link href="https://cdn.staticfile.org/font-awesome/5.11.2/css/all.min.css" rel="stylesheet">
	<link rel="stylesheet" type="text/css" href="/static/m.css" >
	
</head>
<body>
<div id="window-mmask" class="window-mmask" ><div class="window-mmask-msg" >页面加载中,请稍候...</div></div>
<div class="easyui-layout" data-options="fit:true"  >
	<div data-options="region:'center'" >
		<table id="gridList" ></table>
	</div>
</div>
<div id="searchbar">
<div class="maction">
		<a href="javascript:void(0)" id="addButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-plus mbutton'">新增</a>
		<a href="javascript:void(0)" id="editButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-pencil-alt mbutton'">编辑</a>
		<a href="javascript:void(0)" id="removeButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-trash-alt mbutton color-c5'">删除</a>
		<a href="javascript:void(0)" id="saveButton" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-save mbutton'">保存</a>
</div>
<form id="searchForm" >
	查询列<input id="search-字段名" name="字段名" class="easyui-textbox" >
	查询列<input id="search-字段名" name="字段名" class="easyui-textbox" >
	<a id="searchButton" href="javascript:void(0)" class="easyui-linkbutton" data-options="plain:true,iconCls:'fas fa-search mbutton'" >查询</a>
</form>
</div>
<script src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js"></script>
<script src="/static/basic/plugins/easyui/jquery.easyui.min.js"></script>
<script src="/static/init.js"></script>
<script src="/static/basic/plugins/easyui/locale/easyui-lang-zh_CN.js"></script>	
<script src="/static/searchEdit.js"></script>
<!-- <script src="/static/basic/plugins/moment/moment.min.js"></script> -->
<script>
var options={
	page_id:235,
	grid_id:"gridList",
	sqlname:"grid_235_sys_action",
	showCheckbox:false,
	rownumbers:false,
};
var editRow=null;
//document ready
$(function(){
	grid1=new uniontrip.datagrid.searchEdit(options);
	
	$('#searchButton').bind('click',grid1.load);//查询操作绑定事件
	//row
	$('#addButton').bind('click', addRow);//新增行绑定事件
	$('#editButton').bind('click',grid1.editRow);//编辑按钮绑定事件
	$('#removeButton').bind('click',grid1.remove);//删除行绑定事件
	$('#saveButton').bind('click', grid1.accept);//保存datagrid绑定事件
	//$('#cancelEditButton').bind('click',grid1.cancelEditing);//取消行编辑绑定事件
	//$('#endEditingButton').bind('click', grid1.endEditing);//结束行编辑绑定事件
	//$('#rejectButton').bind('click', grid1.rejectChanges);//撤销编辑绑定事件		
    //$('#showChangesButton').bind('click',grid1.showChanges);//信息变更提示

    //初始化搜索框
    initsearch();
    EditDialog=$("<div/>").appendTo("body").dialog({
		title:"新增气站",
		cls:"m-dialog",
		/*width:'100%',
		height:dialogHeight,*/
		href:'/grid/form/insert/view?grid_id=235',
		//href:'edit.html',
		modal:true,
		closed:true,
		maximized:true,
		onClose:function(){
			console.log('onClose');
			
		},
		onBeforeClose:function(){
			
		},
		 buttons: [{
			text:'保存',
			iconCls:'fas fa-save mbutton',
			handler:save
		},{
			text:'取消',
			iconCls:'fas fa-times mbutton',
			handler:function(){
				EditDialog.dialog('close')
			}
		}],
		onOpen:function(){
			console.log('onOpen');
			
		},
		onLoad:function(){
			console.log('onLoad');
			
			
		}
	});
});

function save(){
	if($("#form-1").form('enableValidation').form('validate')){
		$.post("/authenticated/gas/station/save",$("#form-1").serializeObject(),function(result){
			if(result.success){
				info( "保存成功！");
				EditDialog.dialog('close');
				grid1.load();
			}else{
				$.messager.alert("提示", "保存失败！<br>"+result.message);
			}
		});
	}
}
/**
 * 新增一行
 */
function addRow(){
//ROW
	var newRowData={id:guid()};//初始化行数据,creator_id:sessionuser.id,creator_name:sessionuser.nickname,create_time:moment().format('YYYY-MM-DD')
	grid1.grid.datagrid('append',newRowData);	
}
function onUpdate(){
	var selectRows=grid1.grid.datagrid('getSelections');
	if(selectRows.length>0){
		parent.addTab("编辑["+selectRows[0].id+"]","/view/sys/actionform.html?id="+selectRows[0].id);
	}else{
		$.messager.alert("提示", "请选择一条数据！");
	}
}
/**
 * 删除提交
 * @param selectRow
 */
function deleteSubmit(selectRow){
	$.post("/authenticated/ajax/update/grid_sys_action-delete",JSON.stringify({ids:[selectRow.id]}),function(result){
		if(result.status==200){
			$.messager.alert("提示", "删除成功！");
			grid1.load();
		}
	});
}

function onDeleteRow(){
	gridConfirm(grid1.grid,"是否确认删除",deleteRow);
}
function deleteRow(row){
	$.post("/authenticated/xx/delete",JSON.stringify({"id":row.id}),function(result){
		if(result.status==200){
			$.messager.alert("提示", "删除成功！");
			grid1.load();
		}else{
			$.messager.alert("提示", "删除失败！<br>"+result.message);
		}
	});
}


/**
 * 初始化搜索条件
 */
function initsearch(){
	/*$('#search-product_class_id').combotree({
		panelHeight:'auto',
		icons: [{
			iconCls:'icon-clear',
			handler:function(){
				$('#search-product_class_id').combotree('clear');
			}
		}],
	    data:grid1.combotreeDatas.product_class_id
	});
	//初始化combobox例子
	$('#search-status').combobox({
		panelHeight:'auto',
		editable:false,
		valueField:'code_value',
		textField:'code_name',
		icons: [{
			iconCls:'icon-clear',
			handler:function(e){
				$(e.data.target).combobox('clear');
			}
		}],
	    data:grid1.comboboxDatas.status
	});*/
}
</script>
</body>
</html>